package com.heyqing.prepare.recursive;

import com.heyqing.prepare.Tools;

/**
 * ClassName:TestEntry
 * Package:com.heyqing.prepare.recursive
 * Description:
 * 递归测试入口
 *
 * @Date:2024/7/22
 * @Author:Heyqing
 */
public class RecursiveMethodTestEntry {
    public static void main(String[] args) {
        calculateNFactorialTest();
        printIToJTest();
        addArrayTest();
        fibonacciTest();
    }

    /**
     * 斐波那契测试
     */
    private static void fibonacciTest() {
        int n = 6;
        int fibonacci = RecursiveMethod.fibonacci(n);
        Tools.print("斐波那契测试", n, "" + fibonacci);
    }

    /**
     * 数组求和
     */
    private static void addArrayTest() {
        //目标数组
        int[] array = {1, 2, 3, 4, 5}; //TODO sum = 15
        int sum = RecursiveMethod.addArray(array);
        Tools.print("数组求和", "{1, 2, 3, 4, 5}", "求和：" + sum);
    }

    /**
     * 打印 i 到 j
     */
    private static void printIToJTest() {
        Tools.separate();
        RecursiveMethod.printIToJ(0, 10);
        Tools.separate();
    }

    /**
     * 求N的阶乘
     */
    private static void calculateNFactorialTest() {
        int N = 5; //TODO 5!应为120
        int nFactorial = RecursiveMethod.calculateNFactorial(N);
        Tools.print("求N的阶乘", N, N + "的阶乘为：" + nFactorial);
    }
}
